from utils import *

class Camera(object):
    def __init__(self, game):
        self.x, self.y = (0,0)
        self.screen = game.screen
        self.size = game.screen_size
    
    def set_limits(self, minx, maxx, miny, maxy):
        self.minx = minx
        self.maxx = maxx
        self.miny = miny
        self.maxy = maxy
    
    def center(self, x, y):
        w, h = self.size
        self.x = Clamp(x - w/2, self.minx, self.maxx)
        self.y = Clamp(y - h/2, self.miny, self.maxy)
    
    def blit(self, image, rect, area = None):
        x,y = rect[0], rect[1]
        self.screen.blit(image, (x - self.x, y - self.y), area)
